package com.my.xl.salary.billdemo.dao;

import com.alibaba.fastjson.JSON;
import com.my.xl.salary.billdemo.mapper.SalaryBillMapper;
import com.my.xl.salary.billdemo.pojo.SalaryBill;
import com.my.xl.salary.billdemo.pojo.SalaryLogin;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class BillDao {
    @Resource
    private SalaryBillMapper billMapper;

    //查询本人的工资条
    public SalaryBill checkSalary(Map map) {
        System.out.println(JSON.toJSONString(map)+"<==checkSalary=BillDao=查询工资的参数");
        return billMapper.checkSalary(map);
    }

    public List<SalaryBill> checkExportData(String userId, String year, ArrayList<String> monthArr) {
        Map map = new HashMap<>();
        map.put("userId",userId);
        map.put("year",year);
       return billMapper.checkExportData(map);
    }

    public List<SalaryBill> checkExportData2(String userId, String year, ArrayList<String> monthArr) {
        Map<String,Object> map = new HashMap<>();
        map.put("userId",userId);
        map.put("year",year);
        map.put("monthArr",monthArr);
        return billMapper.checkExportData2(map);
    }

    //插入数据
    public int insertBill(SalaryBill s) {
        return billMapper.insert(s);
    }

    //查询之前是否导入过工资
    public SalaryBill isExportByNameAndMOnth(String name, String month, String year) {
        Map<String, Object> map = new HashMap<>();
        map.put("name",name);
        map.put("month",month);
        map.put("year",year);
        return billMapper.isExist(map);
    }
    //修改工资条
    public boolean updateBill(SalaryBill s) {
        int num=billMapper.updateBill(s);
        return num>0;
    }
}
